package qilin.primitives;


/**
 * 
 * Represents a non-interactive commitment scheme with a trapdoor. A trapdoor non-interactive commitment scheme is 
 * a non-interactive commitment scheme where one of the parties (either the verifier or the committer) may know a 
 * trapdoor: a secret key that allows a committer to equivocate or a verifier to learn the committed value.
 * These two cases are represented by the sub-interfaces {@link EquivocatingCommitter} and {@link RevealingVerifier}.
 *
 */
public interface TrapdoorNonInteractiveCommitment extends
		NonInteractiveCommitment {
	/**
	 * Represents a commitment-scheme committer with a trapdoor that breaks the commitment's binding property.
	 *
	 * @param <C> Commitment type.
	 * @param <E> Element type.
	 * @param <R> Randomness type
	 */
	public interface EquivocatingCommitter<C, E, R> extends 
		NonInteractiveCommitment.Committer<C, E, R> {
		
		/**
		 * Return a valid opening to a value for 
		 * a given commitment for which some opening is known 
		 * @param oldvalue known opening message 
		 * @param oldrandom known opening randomness
		 * @param newvalue value to which the commitment should be opened
		 * @return new randomness so that commit(newvalue,newrandom)=commit(oldvalue,oldrandom)
		 */
		public R equivocate(E oldvalue, R oldrandom, E newvalue);
	}
	
	/**
	 * Represents a commitment-scheme verifier with a trapdoor that breaks the commitment's hiding property.
	 *
	 * @param <C> Commitment type.
	 * @param <E> Element type.
	 * @param <R> Randomness type
	 */
	public interface RevealingVerifier<C, E, R> extends 
	NonInteractiveCommitment.Verifier<C, E, R> {
		/**
		 * Break the hiding property of the commitment.
		 * 
		 * @param commitment the commitment generated by a call to {@link NonInteractiveCommitment.Committer#commit(Object,Object)}.
		 * @return the element committed to by the commitment.
		 */
		public E reveal(C commitment);
	}

}
